<template>
  <div class="app-container">
    <!-- 表格 -->
    <el-table
      :key="tableKey"
      ref="table"
      v-loading="listLoading"
      :data="list"
      border
      fit
      highlight-current-row
      style="width: 100%"
    >
      <el-table-column label="顺序" prop="id" align="center" />
      <el-table-column label="拍品编号" prop="product.id" align="center" />
      <el-table-column label="拍品名称" header-align="center" min-width="150">
        <template slot-scope="{ row }">
          <template v-if="row.product">
            <el-image
              style="width: 40px; height: 40px; text-align: center"
              :src="row.product.image"
              :preview-src-list="[row.product.image]"
            />
            <span style="vertical-align: top; margin-left: 10px">{{
              row.product.name
            }}</span>
          </template>
          <template v-else>
            <el-image
              style="width: 40px; height: 40px; text-align: center"
              :src="row.product_image"
              :preview-src-list="[row.product_image]"
            />
            <span style="vertical-align: top; margin-left: 10px">{{
              row.product_name
            }}</span>
          </template>
        </template>
      </el-table-column>
      <el-table-column label="所属拍卖场次" align="center">
        <template slot-scope="{ row }">{{
          row.product &&
            row.product.auction_session &&
            row.product.auction_session.name
        }}</template>
      </el-table-column>
      <el-table-column label="拍品类型" align="center">
        <template slot-scope="{ row }">{{
          row.product && row.product.type == 0
            ? "首次上架"
            : row.product && row.product.type == 1
              ? "续拍商品"
              : ""
        }}</template>
      </el-table-column>
      <el-table-column label="拍品状态" align="center">
        <template slot-scope="{ row }">
          <template v-if="row.product">
            {{
              row.product.status == 0
                ? "待审核"
                : row.product.status == 1
                  ? "待拍卖"
                  : row.product.status == 2
                    ? "拍卖中"
                    : row.product.status == 3
                      ? "已流拍"
                      : row.product.status == 4
                        ? "已截拍"
                        : row.product.status == 5
                          ? "已失败"
                          : row.product.status == 6
                            ? "锁定中"
                            : row.product.status == 7
                              ? "已完成"
                              : ""
            }}
          </template>
        </template>
      </el-table-column>
      <el-table-column label="店铺" align="center">
        <template slot-scope="{ row }">
          {{
            (row.shopping && row.shopping.name) ||
              (row.shopping && row.shopping.shopping_name)
          }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="成交价" prop="real_pay" />
      <el-table-column
        align="center"
        label="平台服务费"
        prop="deal_server_money"
      />
      <el-table-column align="center" label="提货时间" prop="pick_goods_at" />
      <!-- <el-table-column label="操作" align="center">
        <template slot-scope="{row}">
          <el-button size="mini" plain type="success" @click="handleLook(row.id)">
            查看
          </el-button>
        </template>
      </el-table-column> -->
    </el-table>

    <!-- 分页 -->
    <div v-if="total > 0" style="text-align: right">
      <pagination
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.per_page"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
import { getHasPickup } from '@/api/common'
import waves from '@/directive/waves' // waves directive
import Pagination from '@/components/Pagination' // secondary package based on el-pagination

export default {
  name: 'AuctionGoodExtract',
  components: {
    Pagination
  },
  directives: {
    waves
  },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        per_page: 20
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      getHasPickup(this.listQuery)
        .then((response) => {
          const { data, total } = response.data
          this.list = data
          this.total = total
        })
        .finally(() => {
          this.listLoading = false
        })
    }
    // 查看
    // handleLook(row) {
    //   this.$router.push('/member/detail/' + row.id)
    // }
  }
}
</script>
